using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication11.Models.Mapping
{
    public class MsgSMSLoggingMap : EntityTypeConfiguration<MsgSMSLogging>
    {
        public MsgSMSLoggingMap()
        {
            // Primary Key
            this.HasKey(t => t.LogID);

            // Properties
            // Table & Column Mappings
            this.ToTable("MsgSMSLogging");
            this.Property(t => t.LogID).HasColumnName("LogID");
            this.Property(t => t.SMSID).HasColumnName("SMSID");
            this.Property(t => t.ServiceID).HasColumnName("ServiceID");
            this.Property(t => t.SendingTime).HasColumnName("SendingTime");
            this.Property(t => t.RetValue).HasColumnName("RetValue");

            // Relationships
            this.HasOptional(t => t.MsgDetail)
                .WithMany(t => t.MsgSMSLoggings)
                .HasForeignKey(d => d.SMSID);
            this.HasOptional(t => t.MsgService)
                .WithMany(t => t.MsgSMSLoggings)
                .HasForeignKey(d => d.ServiceID);

        }
    }
}
